<template>
  <div class='container'>
     <el-dialog width="900px" title="题目预览" :visible="showDialog" @close="close">
      <el-form :model="DetailsList">
        <el-row :gutter="20">
        <el-col :span="6"><div class="grid-content bg-purple">【题型】:{{ DetailsList.questionType === '1' ? '单选' : DetailsList.questionType === '2' ? '多选' : '简答题' }}</div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">【编号】:{{ DetailsList.id }}</div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">【难度】:{{ DetailsList.difficulty === '1' ? '简单' : DetailsList.difficulty === '2' ? '一般' : '困难' }}</div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">【标签】:{{ DetailsList.tags }}</div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">【学科】:{{ DetailsList.subjectName }}</div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">【目录】:{{ DetailsList.directoryName }}</div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">【方向】:{{ DetailsList.direction }}</div></el-col>
      </el-row>
      <hr>
          <div>【题干】:</div>
          <div class="questionStyle" v-html="DetailsList.question"></div>
          <div v-if="DetailsList.questionType === '1'">
            <div>单选题 选项：（以下选中的选项为正确答案）</div>
            <el-radio-group :value="1">
              <el-radio
              style="display: block; padding: 8px 0"
              v-for="item in DetailsList.options"
              :key="item.id"
              :label="item.isRight"
              >
              {{ item.title }}
              </el-radio>
            </el-radio-group>
          </div>
           <div v-else-if="DetailsList.questionType === '2'">
            <div>多选题 选项：（以下选中的选项为正确答案）</div>
            <el-checkbox-group :value="[1]">
              <el-checkbox
              style="display: block; padding: 8px 0"
              v-for="item in DetailsList.options"
              :key="item.id"
              :label="item.isRight"
              >
              {{ item.title }}
              </el-checkbox>
            </el-checkbox-group>
          </div>
        <hr>
          <span>【参考答案】:</span>
          <el-button type="danger" @click="show=DetailsList.videoURL">视频答案预览</el-button>
          <video style="display:block; width: 400px;height: 300px;" :src="DetailsList.videoURL" controls v-if="show" autoplay></video>
        <hr>
          <span >【答案解析】:</span>
          <div style="display: inline-block;" v-html="DetailsList.answer"></div>
      <hr>
        <span>【题目备注】:{{DetailsList.remarks}}</span>
      <el-row type="flex" justify="end"  class="ShutDownButton">
        <el-col :span="2">
          <el-button type="primary" @click="close">关闭</el-button>
        </el-col>
      </el-row>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { detail } from '@/api/hmmm/questions'
export default {
  props: {
    showDialog: {
      type: Boolean,
      default: false
    },
    currentId: {
      type: Number,
      default: null
    }
  },
  data () {
    return {
      DetailsList: {
        id: null, // 编号
        questionType: '', // 题型
        difficulty: '', // 难度
        tags: '', // 标签
        subjectName: '', // 学科
        directoryName: '', // 目录
        direction: '', // 方向
        question: '', // 题干
        options: [], // 选项
        videoURL: '', // 解析视频
        answer: '', // 答案解析
        remarks: ''// 题目备注
      },
      show: false // 播放器
    }
  },
  methods: {
    close () {
      this.$emit('update:showDialog', false)
      this.show = false
    },
    async getDetail () {
      // console.log(this.currentId)
      const { data } = await detail(this.currentId)
      this.DetailsList = data
      // console.log(this.DetailsList)
    }
  }
}
</script>

<style scoped lang='scss'>
.grid-content {
  padding: 10px 0;
 }
 .ShutDownButton {
  padding: 10px 20px 20px;
 }
.questionStyle{
  color: blue;
}
 </style>
